package ui.panel.warriorLevelups {

	import beans.WarriorBean;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.geom.Rectangle;
	
	import globals.ButtonType;
	import globals.Global;
	
	import ui.component.Button;
	import ui.component.Label;
	import ui.component.Page;
	import ui.component.ScaleBitmap;
	import ui.component.TextButton;
	import ui.face.Bar;
	
	import util.UIUtil;
	/**
	 * 英雄晋级后的英雄信息 
	 * @author luguobin
	 */	
	public class WarriorNextInfo extends Sprite {
		
		private var nameLabel:Label;
		private var jobLabel:Label;
		private var levelLabel:Label;
		
		private var warriorView:Bitmap;
		private var expBar:Bar;
		
		private var powerLabel:Label;
		private var magicLabel:Label;
		private var intLabel:Label;
		private var lifeLabel:Label;
		
		private var presenceButton:TextButton;
		
		private var warriorBean:WarriorBean;

		public function WarriorNextInfo() {
			
			var bg:ScaleBitmap= new ScaleBitmap(Global.assetsManager.getAssetsAsBitmapData("tower_bg"));
			bg.scale9Grid = new Rectangle(35, 35, 14, 14);
			bg.width = 150;
			bg.height = 355;
			this.addChild(bg);
			
			nameLabel = new Label(14, 0xFFFFFF, true);
			nameLabel.x = 20;
			nameLabel.y = 20;
			addChild(nameLabel);
			jobLabel = new Label();
			jobLabel.x = 50;
			jobLabel.y = 30;
//			addChild(jobLabel);
			levelLabel = new Label(12, 0xFFFFFF, true);
			levelLabel.x = 84;
			levelLabel.y = 22;
			addChild(levelLabel);
			
			warriorView = new Bitmap();
			addChild(warriorView);
			expBar = new Bar("warrior_exp_track", "warrior_exp_bar_bg");
			expBar.x = 26;
			expBar.y = 250;
			addChild(expBar);
			
			powerLabel = new Label(12, 0xFFFFFF);
			powerLabel.x = 30;
			powerLabel.y = 160;
			addChild(powerLabel);
			magicLabel = new Label(12, 0xFFFFFF);
			magicLabel.x = 30;
			magicLabel.y = 180;
			addChild(magicLabel);
			intLabel = new Label(12, 0xFFFFFF);
			intLabel.x = 30;
			intLabel.y = 200;
			addChild(intLabel);
			lifeLabel = new Label(12, 0xFFFFFF);
			lifeLabel.x = 30;
			lifeLabel.y = 220;
			addChild(lifeLabel);
			
			presenceButton = UIUtil.getTextButton(0,"派 驻",  ButtonType.BUTTON_BLUE, presenceHandler);
			presenceButton.x = 50;
			presenceButton.y = 280;
			addChild(presenceButton);
			
			var bean:WarriorBean = new WarriorBean();
			bean.name = "阿波罗";
			bean.job = "太阳神";
			bean.image = "avatar_1_1";
			bean.level = 10;
			bean.exp = 20;
			bean.power = 300;
			bean.magic = 400;
			update(bean);
		}
		
		private function presenceHandler(button:Button):void {
			if (warriorBean != null) {
			}
		}
		
		public function update(bean:WarriorBean):void {
			warriorBean = bean;
			
			nameLabel.text = bean.name;
			jobLabel.text = bean.job;
			levelLabel.text = "等级:" + bean.level.toString();
			warriorView.bitmapData = Global.assetsManager.getAssetsAsBitmapData(bean.image, "warrior");
			warriorView.x = warriorView.width * 0.5 + 10;
			warriorView.y = warriorView.height - 40;
//			expBar.update(bean.exp);
			powerLabel.text = "武力：" + bean.power.toString();
			magicLabel.text = "魔力：" + bean.magic.toString();
			intLabel.text = "内政：" +　bean.intelligence.toString();
			lifeLabel.text = "血量：" + bean.life.toString();
		}
		
		private function pageHandler(num:uint):void {
			
		}
		
		public function clear():void {
			warriorBean = null;
			
			nameLabel.text = jobLabel.text = levelLabel.text = powerLabel.text = magicLabel.text = intLabel.text = "";
			warriorView.bitmapData = null;
			expBar.clear();
		}
	}
}